package rsj.api.product;

import com.rlyy.aibase.utils.base.Box;
import com.rlyy.aibase.utils.base.MapNode;
import common.util.BoxUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rsj.api.user.BaseLink;
import rsj.log.ModuleEnum;
import rsj.log.OperationLog;
import rsj.log.OperationTypeEnum;
import rsj.service.HttpService;
@RestController
public class GetFilOpeToken extends BaseLink {

    private static final HttpService httpService = HttpService.getInstance();

    @RequestMapping(value = "rsj_prod_upDownToken")
    @OperationLog(description = "下载产品", logType = OperationTypeEnum.DOWNLOAD, logModule = ModuleEnum.PRODUCT_MANAGEMENT)
    public Box executeLink(Box in){
        MapNode data = in.getMapNode("data");
        String $tid = in.getNode("$tid");

        String userId = getUserIdFromToken(in);

        logger.info("GetFilOpeToken::$tid:{},userId:{}", $tid, userId);
        String token = httpService.getUpDownToken(userId, $tid);

        MapNode out = new MapNode();
        out.putNode("File_Token", token);

        return BoxUtil.successBox(in, "获取成功").putMapNode("data", out);
    }

}
